<%@ page contentType="text/html; charset=utf-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
    <title>登录 — 代理管理系统</title>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all" />
    <link rel="stylesheet" type="text/css" href="/css/sx/login/login_black.css"/>
    <script src="/js/sx/login/calc.js" type="text/javascript"></script>
</head>

<body>
<div class="outer-layer">
    <!--左边-->
    <div class="content-left">
        <img src="/images/sx/login/logo_icon.png"/>
        <img src="/images/sx/login/login_background_black.png"/>
    </div>
    <!--右边-->
    <div class="content-rigth">
        <div class="content-rigth-title">
            代理管理系统
        </div>
        <div class="content-rigth-form">
            <!--表单-->
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="form">
<%--                    //TODO 部署时候需要删除默认值--%>
                    <input type="text" id="login" name="login" value="" placeholder="账户"/>
                    <input type="password" id="passWord" name="passWord"  value="" placeholder="密码"/>
                    <div class="code">
                        <input type="text" id="validCode" name="validCode" placeholder="验证码"/>
                        <img onclick="javascript:document.getElementById('codeimage').src='/verifyImg?t=' + Math.random();"
                             id="codeimage" src="/verifyImg" alt="请输入验证码">
                    </div>
                    <input type="button" class="login" value="登  录"/>
                    <%--<input type="submit" lay-submit lay-filter="login" value="登&nbsp&nbsp&nbsp录"/>--%>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function () {
        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , form = layui.form
            , router = layui.router()
            , search = router.search;

        var active = {
            login:function(login,passWord,validCode){
                $.ajax({
                    url: "/toLogin",
                    data: {"login":login,"passWord":passWord,"validCode":validCode},
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if(data.status){
                            layer.msg(data.desc,{icon:1});
                            setTimeout(function () {
                                window.location.href = "/agent/index";
                            }, 1000)
                        }else{
                            layer.msg(data.desc,{icon:2})
                        }
                    }
                });
            }
        };

        $(".login").on('click',function () {
            var type = "login";
            var login = $("#login").val();
            var passWord = $("#passWord").val();
            var validCode = $("#validCode").val();
            active[type] && active[type].call(this,login,passWord,validCode);
        })
    });
</script>
</html>
